package Threads.Patterns.Singleton;

import java.io.Serializable;


//饿汉式
public final class Singleton1 implements Serializable {

    private Singleton1(){}

    private static final  Singleton1 SINGLETON_1=new Singleton1();//这段代码是线程安全的，类加载的过程中，是线程安全的（由JVM保证）


    public static Singleton1 getInstance(){
        return SINGLETON_1;
    }

    public Object readResolve(){//解决反序列化破坏单例的问题
        return SINGLETON_1;
    }
}
